home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-21 | 1.8 KB | 62 lines | [TEXT/ttxt] |
- --<<<-
- -- Filename: ANIMATIN.SX
-
- -- Purpose: To demonstrate how animation works, keeping the
- -- target list unchanged -- that is, without using
- -- TargetListAction
-
- -- Specialized Classes: (none)
-
- -- Instructions to User: Load this file; it displays a yellow window.
- -- Watch the red ball move between three spots, then loop continuously
-
- -- Author: Douglas Kramer
-
- ------------------------------------------------------------------------
-
- -- Create the yellow window
- global myWindow := new Window boundary:(new Rect x2:500 y2:400)
- myWindow.fill := new Brush color:yellowColor
- myWindow.y := 40
- show myWindow
-
- -- Create the ActionList and ActionListPlayer
- global al := new ActionList
- global alp := new ActionListPlayer actionList:al scale:30
- alp.authorData := myWindow
-
- -- Create a red circle
- global myShape := new TwoDShape target:(new Oval x2:80 y2:80)
- myShape.fill := new Brush color:redColor
- myShape.x := 20
- myShape.y := 30
- prepend myWindow myShape
-
- -- Create an interpolator controller for the window
- global myInterp := new Interpolator space:myWindow clock:alp
- append myInterp myShape
-
- -- Put the interpolator on the target list
- alp.targets[1] := myInterp
-
- -- Create Interpolate actions and append them to the action list
- -- Interpolate from time 0 to 75 ticks
- append al (new InterpolateAction targetNum:1 time:0 \
- destPosition:(new Point x:400 y:300) destTime:75)
-
- -- Interpolate from time 75 to 125 ticks
- append al (new InterpolateAction targetNum:1 time:75 \
- destPosition:(new Point x:400 y:30) destTime:125)
-
- -- Interpolate from time 125 to 200 ticks
- append al (new InterpolateAction targetNum:1 time:125 \
- destPosition:(new Point x:20 y:30) destTime:200)
-
- -- At time 200 jump to time 0
- append al (new TimeAction time:200 destTime:0)
-
- -- Play the action list player
- play alp
-
- -- To increase its rate, try: alp.rate := 2
-